package pt.ipp.estgf.meteorologia;

import pt.ipp.estgf.cmuweatherlib.*;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;

public class FragmentMap extends SupportMapFragment {

	private GoogleMap mMap;
	private Place mPlace;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	public void setPlace(Place p) {
		this.mPlace = p;
	}
	

	@Override
	public void onStart() {
		super.onStart();
		mMap = super.getMap();
		mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
		mMap.getUiSettings().setZoomControlsEnabled(false);
		LatLng mLL = new LatLng(mPlace.getLatitude(), mPlace.getLongitude());
		mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mLL, 5));
		
		MarkerOptions mOptions = new MarkerOptions();
		mOptions.position(mLL);
		mOptions.title(this.mPlace.getName());
		mMap.addMarker(mOptions);
	}

}
